package com.chinacoal.microservice.controller;

import com.chinacoal.microservice.ContractManagementClient;
import com.chinacoal.microservice.pojo.CcmsSmartleasingAuditRecods;
import com.chinacoal.microservice.pojo.CcmsSmartleasingContract;
import com.chinacoal.microservice.service.ContractManagementService;
import com.chinacoal.microservice.util.PassToken;
import com.chinacoal.microservice.util.QueryCriteria;
import com.chinacoal.microservice.util.Result;
import com.chinacoal.microservice.util.UserLoginToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @author zhuliang
 * @version V1.0
 * @Description: 运维管理-合同管理-后端控制类
 * @date 2020-11-16 10：01
 */
@RestController
public class ContractManagementController implements ContractManagementClient {

    @Autowired
    private ContractManagementService  contractManagementService;

    /**
     * @Description: 获取所有的合同信息（带分页）
     * @author zhuliang
     * @date 2020/11/17 9:21
     */
    @Override
    @UserLoginToken
    public Result<List<CcmsSmartleasingContract>> getAllContract(QueryCriteria queryCriteria, String token) {
        return contractManagementService.getAllContract(queryCriteria, token);
    }

    /**
     * @Description: 退租
     * @author zhuliang
     * @date 2020/11/17 11:19
     */
    @Override
    @UserLoginToken
    public Result rentCancellation(CcmsSmartleasingContract contract, String token) {
        return contractManagementService.rentCancellation(contract, token);
    }

    /**
     * @Description: 根据合同id查询合同信息
     * @author zhuliang
     * @date 2020/11/17 13:57
     */
    @Override
    @UserLoginToken
    public Result<CcmsSmartleasingContract> getContractById(String pkContractId, String token) {
        return contractManagementService.getContractById(pkContractId, token);
    }

    /**
     * @Description: 修改合同信息和租户信息
     * @author zhuliang
     * @date 2020/11/17 14:41
     */
    @Override
    @UserLoginToken
    public Result updateContract(CcmsSmartleasingContract contract, String token) {
        return contractManagementService.updateContract(contract, token);
    }

    /**
     * @Description: 审核
     * @author zhuliang
     * @date 2020/11/17 15:56
     */
    @Override
    @UserLoginToken
    public Result reviewContract(CcmsSmartleasingAuditRecods auditRecods, String token) {
        return contractManagementService.reviewContract(auditRecods, token);
    }

    /**
     * @Description: 根据合同id批量删除合同信息
     * @author zhuliang
     * @date 2020/11/17 17:03
     */
    @Override
    @UserLoginToken
    public Result deleteContract(String deleteId, String token) {
        return contractManagementService.deleteContract(deleteId, token);
    }

    /**
     * @Description: 条件查询合同信息（带分页）
     * @author zhuliang
     * @date 2020/11/18 10:38
     */
    @Override
    @UserLoginToken
    public Result<List<CcmsSmartleasingContract>> getContractByCondition(QueryCriteria queryCriteria, String token) {
        return contractManagementService.getContractByCondition(queryCriteria, token);
    }

    /**
     * @Description: 添加合同信息
     * @author zhuliang
     * @date 2020/11/18 14:11
     */
    @Override
    @UserLoginToken
    public Result addContract(CcmsSmartleasingContract contract, String token) {
        return contractManagementService.addContract(contract, token);
    }
}
